Multimedia API Reference

September 12, 2016 | 24.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nvee_backend.md
Go to the documentation of this file.
1 Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
2 
3 @page nvvid_backend_group 4 Ways to Video Decode with GIE Processing Sample
4 @{
5 
6  - [Overview](#overview)
7  - [Key Structure and Classes](#key)
8  - [Command Line Options](#options)
9 
10 - - - - - - - - - - - - - - -
11 <a name="overview">
12 ## Overview ##
13 
14 This use case application showcases a typical appliance performing intelligent video analytics.
15 Application areas include public safety, smart cities, and autonomous machines. This example demonstrates
16 four (4) concurrent video streams going through a decoding process using the on chip decoders, video scaling using on
17 chip scalar, and GPU compute. For simplicity of demonstration, only one of the channels will use GIE to perform object identification
18 and generate bounding box around the identified object. This sample also uses video converter functions
19 to do various format convrsions and uses EGLImage to demonstrate buffer sharing and image display capability.
20 
21 In this sample, object detection is limited to identifying cars in video streams of 960 x 540 resolution,
22 running up to 14 FPS. The network is based on GoogleNet. The inference is performed on a frame-by-frame basis
23 and no object tracking is involved. Note that this network is intended to be purely an example to showcase
24 GIE usage to build the compute pipeline quickly. The trained GoogleNet is provided as source and was trained
25 using NVIDIA DIGITS with roughly 3000 frames taken from 5-10 feet elevation. Varying levels of detection accuracy are expected based on the video samples fed in. Given that this sample is locked to perform at half-HD resolutions under 10 FPS, video feeds with higher FPS for inference will show stuttering during playback.
26 
27 `NvEGLImageFromFd` is NV-defined API to return an EGLImage pointer from the file descriptor buffer that is allocated by way of Tegra mechanism. EGLImage buffer is then used by GIE to render the bounding box to the image.
28 
29 This sample does not require a camera.
30 
31 The image below shows a sample block diagram.
32 
33 ![ ](nvee_backend_one.jpg)
34 
35 The images below shows data flow details for the channel using GIE.
36 
37 ![ ](nvee_backend_two.jpg)
38 
39 `NvEGLImageFromFd` is NVIDIA defined API to return an `EGLImage` pointer form the file
40 descriptor buffer that is allocated by way of Tegra mechanism. `EGLImage` buffer is
41 then used by GIE to render the bounding box to the image.
42 
43 #### Prerequisites ####
44 Before running the sample, you must have the following:
45 
46 * CUDA 8.0 Toolkit for L4T Rel 24.2
47 * GPU Inference Engine (GIE)
48 * OpenCV4Tegra
49 * README that provides details on the environment requirements to build and run the sample
50 
51 - - - - - - - - - - - - - - -
52 <a name="key">
53 ## Key Structure and Classes ##
54 
55 There is a global structure `struct context_t` that manages all the resources in the application.
56 
57 |Element|Description|
58 |-------|-----------|
59 |[NvVideoDecoder](classNvVideoDecoder.html)|Contains all video decoding-related elements and functions.|
60 |[NvVideoConverter](classNvVideoConverter.html)|Contains elements and functions for video format conversion.|
61 |NvEglRenderer|Contains all EGL display rendering-related functions.|
62 |egl_image|The EGLImage used for CUDA processing.|
63 |conv_output_plane_buf_queue|Output plane queue for video conversion.|
64 |dec_capture_loop|The thread handler for decoding capture loop.|
65 
66 ### %NvVideoDecoder ###
67 
68 The [NvVideoDecoder](classNvVideoDecoder.html) class creates a new V4L2 Video Decoder.
69 The following table describes the key %NvVideoDecoder members that this sample uses.
70 
71 |Member|Description|
72 |-------------|---|
73 |[output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5) |Holds the V4L2 output plane.|
74 |[capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d)|Holds the V4L2 capture plane.|
75 |createVideoDecoder |Static function to create video decode object.|
76 |subscribeEvent|Subscribes event.|
77 |setExtControls |Sets external control to V4L2 device.|
78 |setOutputPlaneFormat|Sets output plane format.|
79 |setCapturePlaneFormat|Sets capture plane format.|
80 |getControl|TBD|
81 |dqEvent|Dequeues the devent reported by the V4L2 device.|
82 |isInError|Checks if under error state.|
83 
84 ### %NvVideoConverter ###
85 
86 The [NvVideoConverter](classNvVideoConverter.html) class packages all video converting related elements and functions.
87 It performs color space conversion, scaling and
88 conversion between hardware buffer memory and software buffer memory.
89 The following table describes the key %NvVideoConverter members that this sample uses.
90 
91 |Member|Description|
92 |-------------|---|
93 |[output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5) |Holds the output plane.|
94 |[capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d)|Holds the capture plane.|
95 |[waitForIdle](classNvVideoConverter.html#a2f5d1a234427862adf9cae7323b5e24c) |Waits until all the buffers queued on the output plane are converted and dequeued from the capture plane. This is a blocking method.|
96 |[setCapturePlaneFormat](classNvVideoConverter.html#ad91e70f0e8b5f5a8b4deefa5a26ffe85)|Sets the format on the converter capture plane.|
97 |[setOutputPlaneFormat](classNvVideoConverter.html#a38b53f4d1e2c357360893756f417faf6) |Sets the format on the converter output plane.|
98 
99 Both `NvVideoDecoder` and `NvVideoConverter` contains 2 key elements: `output_plane` and `capture_plane`.
100 This object is dervied from class type [NvV4l2ElementPlane](group__ee__nvv4lelementplane__group.html).
101 
102 ### %NvV4l2ElementPlane ###
103 
104 [NvV4l2ElementPlane](group__ee__nvv4lelementplane__group.html) creates an [NVv4l2Element](classNvV4l2Element.html) plane.
105 The following table describes the key %NvV4l2ElementPlane members used in this sample.
106 
107 |Member |Description|
108 |-------------------|---|
109 |[setupPlane](classNvV4l2ElementPlane.html#a89959f455e5222f686187cc826b1b345) |Sets up the plane of V4l2 element.|
110 |[deinitPlane](classNvV4l2ElementPlane.html#af89cfe87d8f818beb0478bcf5b72574c) |Destroys the plane of V4l2 element.|
111 |[setStreamStatus](classNvV4l2ElementPlane.html#a03164dde4d7ab41f3e92b41e13059316) |Starts/Stops the stream.|
112 |[setDQThreadCallback](classNvV4l2ElementPlane.html#a37f213325e0e4857180f5b2319317d6a)|Sets the callback function of the `dqueue` buffer thread.|
113 |[startDQThread](classNvV4l2ElementPlane.html#a31f77f5e5ed1f320caa44a868a7cbedd) |Starts the thread of the `dqueue` buffer.|
114 |[stopDQThread](classNvV4l2ElementPlane.html#aa798d14493de321fa90aeab6d944ca87) |Stops the thread of the `dqueue` buffer.|
115 |[qBuffer](classNvV4l2ElementPlane.html#af4d52964fcfd37082f47682e457f5e95) |Queues a V4l2 buffer from the plane.|
116 |[dqBuffer](classNvV4l2ElementPlane.html#a8dfcbc666ee6f36a02abfb1170ae05cd) |Dequeues a V4l2 buffer from the plane.|
117 |[getNumBuffers](classNvV4l2ElementPlane.html#ac5cd394a7e0a4afd69395759aeac8787) |Gets the number of the V4l2 buffer.|
118 |getNumQueuedBuffers |Gets the number of the V4l2 buffer in the queue.|
119 |[getNthBuffer](classNvV4l2ElementPlane.html#a868d438908f3d267dd4af1033133892f) |Gets the \c %NvBuffer queue object at index N.|
120 
121 ### %GIE_Context ###
122 
123 GIE_Context provides a series of interfaces to load Caffe model and perform inference.
124 The following table describes the key %GIE_Context members used in this sample.
125 
126 |GIE_Context|Description|
127 |-----------|-----------|
128 |gie_alloc|Sets up all resources and parameters.|
129 |gie_free|Clears all resources.|
130 |caffeToGIEModel|Loads Caffe mode to GIE model.|
131 |doInference|Interface for inference after GIE model is loaded.|
132 |parse_bbox|Parses Google net's output results.|
133 |parse_hel_bbox|Parses Nvhel net's output results.|
134 |parse_net|Parses net info from proto file.|
135 
136 2 global functions are used to create and destroy EGLImage from `dmabuf` file descriptor.
137 
138 |Global Function|Description|
139 |---------------|-----------|
140 |NvEGLImageFromFd|Creates EGLImage from dmabuf fd.|
141 |NvDestroyEGLImage|Destroys the EGLImage.|
142 
143 - - - - - - - - - - - - - - -
144 <a name="options">
145 ## Command Line Options ##
146 
147 To run the sample, execute:
148 
149  backend <channel-num> <in-file1> <in-file2>... <in-format> [options]
150 
151 The following video formats are supported for use with command line options:
152 
153  * H.264
154  * H.265
155 
156 ### Options ####
157 
158 The table below describes the available options.
159 
160 |Command|Description|
161 |---------------|-----------|
162 |-h, --help|Prints the help text.|
163 |-fps <fps>|Displays rate in frames per second. Default = 30.|
164 |--s| Provides a statistic of each channel.|
165 |-run-opt <0-3>| 0=default, 1=parser only, 2=parser + decoder, 3=parser + decoder + VIC|
166 |--input-nalu|Specifies that the default input to the decoder is in nalu units.|
167 |--input-chunks|Specifies that the default input to the decoder is in chunk of bytes.|
168 |--gie-deployfile|Sets the deploy file name.|
169 |--gie-modelfile|Sets the model file name.|
170 |--gie-proc-interval|Sets the process interval; 1 frame is processed every gie-proc-interval.|
171 |--gie-float16|0=default, 1=float16, 2=float32.|
172 
173 For X11 technical details, see:
174 
175 http://www.x.org/docs/X11/xlib.pdf
Defines a helper class for V4L2 Video Decoder.
Defines a helper class for operations performed on a V4L2 Element plane.
Class representing a buffer.
Definition: NvBuffer.h:85
EGLImageKHR NvEGLImageFromFd(EGLDisplay display, int dmabuf_fd)
This method must be used for getting EGLImage from dmabuf-fd.
Defines a helper class for V4L2 Video Converter.
NvEglRenderer is a helper class for rendering using EGL and OpenGL ES 2.0.
Definition: NvEglRenderer.h:74
int NvDestroyEGLImage(EGLDisplay display, EGLImageKHR eglImage)
This method must be used for destroying EGLImage object.